<?php
namespace Home\Model;
use Think\Model;

/**
* 
*/
class UsersModel extends Model
{
	
	function get_register($res)
	{
		//dump($res);
		//$sql = $this->fetchSql(true)->add($res);
        //echo $sql;
        $result = $this->add($res);
        if($result)
        {
            $user_id = $result;
        }
        return $user_id;
	}

    function get_userinfo($user_id)
    {
        $field = array(
                'user_id' => $user_id
                );
        //$result = $this->where($field)->fetchSql(true)->find();
        $result = $this->field('*')->where($field)->find();
        //dump($result);
        
        return $result;
    }

    function find_openid($openid)
    {
        $field = array(
               'openid' => $openid
                );
        //$user_id = $this->field('user_id')->where($field)->find();
        
        //return $user_id;

        //$user_id = $this->getField('user_id',$field);//查询某个字段的值
        $user_id = $this->where($field)->getField('user_id');
        return $user_id;
    }
}